﻿
@{
    ViewBag.Title = "_Add";
}
@using Shop.Entity;
@model TGoodsCategory
<link href="~/Content/checkbox/css/build.css" rel="stylesheet" />
<link href="~/Content/checkbox/Font-Awesome/css/font-awesome.min.css" rel="stylesheet" />
<div class="modal fade bs-example-modal-lg" id="Add" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="headerTitle">新增分类</h4>
            </div>
            <div class="modal-body">
                <div class="portlet-body form">
                    @using (Html.BeginForm("AddSave", "goodscategory", FormMethod.Post, new { id = "add", @class = "form-horizontal" }))
                    {

                        @Html.HiddenFor(c => c.Guid)
                        @Html.HiddenFor(c => c.AddTime)
                        @Html.HiddenFor(c => c.OperatorGuid)
                        @Html.HiddenFor(c => c.BusinessGuid)
                        @Html.HiddenFor(c => c.ChainStoreGuid)
                        <div class="form-body">
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        分类名称<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control input-sm input-inline" name="Title" id="Title" datatype="s2-6" nullmsg="请输入分类名称!" sucmsg=" " errormsg="名称至少2个字符,最多6个字符！" value="@Model.Title" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        所属商户<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-4">
                                        @Html.DropDownListFor(c => c.BusinessGuid, ViewData["Business"] as IEnumerable<SelectListItem>, "-所属商户-", new { id = "Business", @class = "form-control input-sm" })
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        上级分类<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-4">
                                        @Html.DropDownListFor(c => c.ParentGuid, (SelectList)ViewData["CateGory"], "-上级分类-", new { id = "Category", @class = "form-control input-sm" })
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        显示顺序<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control input-sm input-inline" name="Sort" id="Sort" datatype="n" nullmsg="请输入显示顺序!" sucmsg=" " errormsg="请输入数字!" value="@Model.Sort" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        备注信息<span class="required"> &nbsp; </span>
                                    </label>
                                    <div class="col-sm-6">
                                        <textarea class="form-control input-sm" rows="3" cols="20" id="Remark" name="Remark" ignore="ignore" datatype="*1-200" errormsg="备注不能超过200个字符!" sucmsg=" ">@Model.Remark</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        包含品牌<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-8" style="padding-left:0px;">
                     
                                            @if (ViewBag.Brand != null)
                                            {
                                                foreach (var item in ViewBag.Brand)
                                                {
                                                    <div class="checkbox checkbox-inline checkbox-primary" style="margin-left:15px;">
                                                        @if (Model.Brand == null || !Model.Brand.Contains(item.Value))
                                                        {
                                                            <input name="Brand" value="@item.Value" id="@item.Value" class="styled" type="checkbox" />
                                                        }
                                                        else
                                                        {
                                                            <input checked="checked" name="Brand" value="@item.Value" id="@item.Value" class="styled" type="checkbox" />
                                                        }

                                                        <label for="@item.Value">@item.Text</label>
                                                    </div>
                                                }
                                            }
                                     
   

                                    </div>
                                </div>
                            </div>
               
         
                            <div class="row">
                                <div class="form-group">
                                    <label for="message-text" class="col-sm-2 control-label"></label>
                                    <div class="col-sm-6" id="tip">
                                        &nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="submit" class="btn btn-primary" value="保存" />
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    }
                </div>
            </div>

        </div>

    </div>
</div>

<script type="text/javascript">
    $('#Add').on('hidden.bs.modal', function (e) {
        layer.closeAll('tips'); //关闭所有的tips层
    })
    function ShowValidformMsg(msg, id) {
        layer.tips(msg, '#' + id, { tipsMore: true });
    }
    $(function () {
        $("#add").Validform({
            showAllError: true,
            ajaxPost: true,
            beforeSubmit: function (curform) {
                layer.msg('正在执行操作...', { icon: 16 });
                return true;
            },
            callback: function (data) {
              
                if (data.succ) {
                    layer.closeAll();

                    $('#Add').modal('hide');
                    if ($("#pageItem").find(".active").find("a").html() != undefined) {
                        $("#pageItem").find(".active").find("a").click();
                    } else {
                        $("#formSearch").submit();
                    }
                } else {
                    parent.layer.alert(data.msg);
                }
            },
            tiptype: function (msg, o) {
                if (msg.trim() != "" && o.type != 1)
                { ShowValidformMsg(msg, $(o.obj).attr("id")); }
            }
        }
        );
    })

</script>